<#assign module="car"/>

<@override name="header">
</@override>
<@override name="body">
<#if message??>
	<div class="alert alert-warning">${message}</div>
</#if>
<div class="row">
	<div class="col-xs-12">
  		<button class="pull-right btn btn-primary" onclick="window.location='${ctx}/carType/toAdd';"><i class="icon-plus"></i>&nbsp;添加汽车类型</button>
  	</div>
</div>
<div class="row margin-top">
	<div class="col-xs-12">
		<div class="panel panel-primary">
		<div class="table-responsive">
			<table class="table table-hover table-striped">
				<thead>
					<tr>
						<th class="col-xs-5" >汽车类型</th>
						<th class="col-xs-5" >汽车顺序</th>
						<th class="col-xs-1">操作</th>
					</tr>
				</thead>
				<tbody>
				<#list lists as cartype>
					<td >${cartype.name}</td>
					<td >${cartype.sequence?if_exists}</td>
					<td  align="center">
						<a href="${ctx}/carType/edit/${cartype.id}" class="btn-link">编辑</a>
						<a href="javascript:;" data-value="${cartype.id}"  class="btn-link deletethis">删除</a>
					</td>
					</tr>
				</#list>
				</tbody>
			</table>
		</div>
	  </div>
	</div>
</div>

</@override>
<@override name="footer">
<script type="text/javascript">
	var thisButton;
	function deleteCarType() {
	    $.post('${ctx}/carType/delete',{'id':thisButton.attr("data-value")},function(data){
	            if(data.success){
	            	thisButton.parent().parent().remove();
	                $.scojs_message('汽车类型删除成功', $.scojs_message.TYPE_OK);
	            } else {
	                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
	            }
	    },'json');
	}
	$(document).ready(function(){
	    $(".deletethis").click(function(){
	          thisButton = $(this);
	          var confirm = $.scojs_confirm({
	            content: "你真的要删除该类型吗？",
	            action:deleteCarType
	          });
	          confirm.show();
	    });
	});
</script>
</@override>
<@extends name="../layout.ftl"/>